<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PersonsForm.aspx.cs" Inherits="Meditek.UI.PersonsForm" MasterPageFile="~/MasterPage.Master"%>

<%@ Register Assembly="Microsoft.Practices.EnterpriseLibrary.Validation.Integration.AspNet"
    Namespace="Microsoft.Practices.EnterpriseLibrary.Validation.Integration.AspNet"
    TagPrefix="cc1" %>
<asp:Content ID="Content2" ContentPlaceHolderID="Body" runat="server">
<br />
  <asp:FormView ID="EditFormView" runat="server" DefaultMode= "Insert" DataSourceID="PersonsDataSource"
	oniteminserting="EditFormView_ItemInserting"  onitemupdating="EditFormView_ItemUpdating" BackColor="#284775" ForeColor="WhiteSmoke" >
	<EditItemTemplate> 
    <table>

	  <tr>
        <td><asp:Label ID="lblidPersonDisplay" runat="server" Text="id Person :" /></td> 
		<td>
		  <asp:TextBox ID="txtidPerson" runat="server" Text='<%# Bind("idPerson") %>'
			ReadOnly="true"
			Width = "70px" 
			TextMode="SingleLine"
			/>
			<br />
            <cc1:PropertyProxyValidator ID="idPersonValidator" runat="server" ControlToValidate="txtidPerson"
               PropertyName="idPerson" SourceTypeName="Meditek.Entities.Persons"></cc1:PropertyProxyValidator>
	    </td>
      </tr>
	  <tr>
        <td><asp:Label ID="lblBloodTypeDisplay"	runat="server"	Text="Name :" /></td>
        <td>
          <asp:DropDownList ID="drlstBloodType" runat="server"	SelectedValue='<%# Bind("BloodType") %>'	Width="100%"
			ondatabinding="drlstBloodType_DataBinding" AppendDataBoundItems="True">
		      <asp:ListItem Text="(None)" Value="" Selected="True" />
		  </asp:DropDownList>
		  <br />
          <cc1:PropertyProxyValidator ID="bloodTypeValidator" runat="server" ControlToValidate="drlstBloodType"
             PropertyName="BloodType" SourceTypeName="Meditek.Entities.Persons"></cc1:PropertyProxyValidator>
        </td>
      </tr>	
	  <tr>
        <td><asp:Label ID="lblDateOfBirthDisplay" runat="server" Text="Date Of Birth :" /></td> 
		<td>
		  <asp:TextBox ID="txtDateOfBirth" runat="server" Text='<%# Bind("DateOfBirth") %>'
			Width = "210px" 
			TextMode="SingleLine"
			/>
			<br />
            <cc1:PropertyProxyValidator ID="dateOfBirthValidator" runat="server" ControlToValidate="txtDateOfBirth"
               PropertyName="DateOfBirth" SourceTypeName="Meditek.Entities.Persons"></cc1:PropertyProxyValidator>
	    </td>
      </tr>
	  <tr>
        <td><asp:Label ID="lblidContactDataDisplay"	runat="server"	Text="FirstName :" /></td>
        <td>
          <asp:DropDownList ID="drlstidContactData" runat="server"	SelectedValue='<%# Bind("idContactData") %>'	Width="100%"
			ondatabinding="drlstidContactData_DataBinding" AppendDataBoundItems="True">
		      <asp:ListItem Text="(None)" Value="" Selected="True" />
		  </asp:DropDownList>
		  <br />
          <cc1:PropertyProxyValidator ID="idContactDataValidator" runat="server" ControlToValidate="drlstidContactData"
             PropertyName="idContactData" SourceTypeName="Meditek.Entities.Persons"></cc1:PropertyProxyValidator>
        </td>
      </tr>	
	  <tr>
        <td><asp:Label ID="lblidPatientDisplay"	runat="server"	Text="idPatient :" /></td>
        <td>
          <asp:DropDownList ID="drlstidPatient" runat="server"	SelectedValue='<%# Bind("idPatient") %>'	Width="100%"
			ondatabinding="drlstidPatient_DataBinding" AppendDataBoundItems="True">
		      <asp:ListItem Text="(None)" Value="" Selected="True" />
		  </asp:DropDownList>
		  <br />
          <cc1:PropertyProxyValidator ID="idPatientValidator" runat="server" ControlToValidate="drlstidPatient"
             PropertyName="idPatient" SourceTypeName="Meditek.Entities.Persons"></cc1:PropertyProxyValidator>
        </td>
      </tr>	
	  <tr>
        <td><asp:Label ID="lblRaceDisplay"	runat="server"	Text="Name :" /></td>
        <td>
          <asp:DropDownList ID="drlstRace" runat="server"	SelectedValue='<%# Bind("Race") %>'	Width="100%"
			ondatabinding="drlstRace_DataBinding" AppendDataBoundItems="True">
		      <asp:ListItem Text="(None)" Value="" Selected="True" />
		  </asp:DropDownList>
		  <br />
          <cc1:PropertyProxyValidator ID="raceValidator" runat="server" ControlToValidate="drlstRace"
             PropertyName="Race" SourceTypeName="Meditek.Entities.Persons"></cc1:PropertyProxyValidator>
        </td>
      </tr>	
	  <tr>
        <td><asp:Label ID="lblSexDisplay"	runat="server"	Text="Name :" /></td>
        <td>
          <asp:DropDownList ID="drlstSex" runat="server"	SelectedValue='<%# Bind("Sex") %>'	Width="100%"
			ondatabinding="drlstSex_DataBinding" AppendDataBoundItems="True">
		      <asp:ListItem Text="(None)" Value="" Selected="True" />
		  </asp:DropDownList>
		  <br />
          <cc1:PropertyProxyValidator ID="sexValidator" runat="server" ControlToValidate="drlstSex"
             PropertyName="Sex" SourceTypeName="Meditek.Entities.Persons"></cc1:PropertyProxyValidator>
        </td>
      </tr>	
	</table>
	</EditItemTemplate>
	<EmptyDataTemplate>
		<b>Persons not found..!</b>
	</EmptyDataTemplate>
	<FooterTemplate>
	  <table>
		<tr>
		  <td><asp:Button ID="btnSave" runat="server"   CausesValidation="True"	CommandName="Insert" Text="Save" CssClass="Button" /></td>
 		  <td><asp:Button ID="btnUpdate" runat="server" CausesValidation="True"  CommandName="Update" Text="Save" CssClass="Button" /></td>
		  <td><asp:Button ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel" Text="Go To Persons List" PostBackUrl="PersonsList.aspx" CssClass="Button" /></td>
        </tr>
	  </table>
	</FooterTemplate>
    </asp:FormView>
	<asp:ObjectDataSource ID="PersonsDataSource" runat="server" 
         SelectMethod="GetById" TypeName="Meditek.UI.PersonsReference.PersonsServiceClient" 
         DataObjectTypeName="Meditek.Entities.Persons" InsertMethod="Insert"  UpdateMethod="Update"
         oninserted="PersonsDataSource_CommitChanges" onupdated="PersonsDataSource_CommitChanges"
         onobjectcreated="PersonsDataSource_ObjectCreated" >
            <SelectParameters>
                <asp:QueryStringParameter Name="idPerson" QueryStringField="idPerson" />
            </SelectParameters>
    </asp:ObjectDataSource>
  </asp:Content>    
